﻿using System;
using System.Collections.Generic;
using PhillyCodeCamp.DTO;
using PhillyCodeCamp.UI;

namespace PhillyCodeCamp.Web
{
    public partial class TaxCalculator : ViewBase, ITaxCalculatorView
    {
        private TaxCalculatorPresenter _presenter;

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            _presenter = new TaxCalculatorPresenter(this);

        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                _presenter.OnViewInitialized();
            }
            _presenter.OnViewLoaded();
        }

        public IList<ILookupDTO> States
        {
            set
            {
                _states.DataSource = value;
                _states.DataBind();
            }
        }

        public string Date
        {
            get { return _submissionDate.Text; }
        }

        public string StateSelected
        {
            get { return _states.SelectedValue; }
        }

        public bool IsBailedOut
        {
            get { return _bailed.Checked; }
        }

        public string TotalIncome
        {
            get { return _totalIncome.Text; }
        }

        public string CalculatedTax
        {
            set { _calculatedTax.Text = value; }
        }

        protected void _submit_Click(object sender, EventArgs e)
        {
            _presenter.ComputeTax();
        }
    }
}
